﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Unity;
using TreeBuilder.Contracts;
using AbstraX.ClientInterfaces;
using AbstraX;
using MvvmTreeView;
using UIObjects;
using TreeBuilder.Services;
using TreeBuilder.ViewModels;

namespace TreeBuilder
{
    public partial class TreeBuilderWindow : UserControl
    {
        public TreeBuilderWindow()
        {
            IoC.RegisterType<ITreeBuilderService, TreeBuilderService>();
            IoC.RegisterType<ITreeBuilderViewModel, TreeBuilderViewModel>();

            InitializeComponent();
        }

        public WindowsStyleTreeView TreeView
        {
            get
            {
                return TreeBuilderTreeView;
            }
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var viewModel = IoC.Resolve<ITreeBuilderViewModel>();

            this.DataContext = viewModel;

            viewModel.OnResetNodeMenu += n =>
            {
                TreeBuilderTreeView.ResetNodeMenu(n);
            };

            TreeBuilderTreeView.Focus();
        }
    }
}

